package 
{
	import flash.display.Sprite;
	import flash.display.StageScaleMode;
	import flash.geom.Rectangle;
	
	/**
	 * ...
	 * @author hbb
	 */
	public class DisplayObject_getRect extends Sprite 
	{
		public function DisplayObject_getRect():void 
		{
			stage.scaleMode = StageScaleMode.NO_SCALE;
			
			mcInDisplayList();
			mcNotInDisplayList();
		}
		
		private function mcNotInDisplayList():void 
		{
			trace('mc Not InDisplayList');
			var child:Sprite = createRect(10, 10, new Rectangle(0, 0, 100, 100), 0xff);
			var mc:Sprite = createRect(0, 0, new Rectangle(0, 0, 100, 100), 0x00);
			mc.addChild(child);
			
			trace(' child.getRect(mc):', child.getRect(mc));
		}
		
		private function mcInDisplayList():void 
		{
			trace('mcInDisplayList');
			var child:Sprite = createRect(10, 10, new Rectangle(0, 0, 100, 100), 0xff);
			var mc:Sprite = createRect(0, 0, new Rectangle(0, 0, 100, 100), 0x00);
			mc.addChild(child);
			addChild(mc);
			
			trace(' child.getRect(mc):', child.getRect(mc));
		}

		
		private function createRect(x:Number, y:Number, rect:Rectangle,color:uint,alpha:Number=1.0):Sprite
		{
			var s:Sprite = new Sprite();
			s.graphics.beginFill(color, alpha);
			s.graphics.drawRect(rect.x, rect.y, rect.width, rect.height);
			s.graphics.endFill();
			s.x = x;
			s.y = y;
			return s;
		}
		
	}
	
}